/**
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Autogenerated file. DO NOT EDIT
package std.core;

{% set maxarity=16 %}

{%- macro genTupleTypeParamsList(narg) -%}
    {%- if narg>0 %}<{% endif %}{% for i in range(narg-1) -%}
        T{{i}}, {{""}}
    {%- endfor -%}
    {%- if narg>0 %}T{{narg-1}}>{% endif %}
{%- endmacro %}

{%- macro genTupleConstructorParams(narg) -%}
    {% for i in range(narg-1) -%}
        p{{i}}: T{{i}}, {{""}}
    {%- endfor -%}
    {%- if narg>0 %}p{{narg-1}}: T{{narg-1}}{% endif %}
{%- endmacro %}

{%- macro genTupleMembers(narg) -%}
    {% for membIdx in range(narg) %}
    public ${{membIdx}}: T{{membIdx}}
    {%- endfor -%}
{%- endmacro %}

{%- macro genTupleCtorSetters(narg) -%}
    {%- for membIdx in range(narg) %}
        this.${{membIdx}} = p{{membIdx}}
    {%- endfor -%}
{%- endmacro -%}

{%- macro genToString(narg) -%}
    public override toString(): string {
        return "" {%- if narg != 0 %} + {%- endif -%}
        {% for membIdx in range(narg) %}
            this.${{membIdx}} {%- if membIdx != narg-1 %} + "," + {%- endif %}
        {%- endfor %}
    }
{%- endmacro -%}

export interface Tuple {}
{% for narg in range(maxarity+1) %}

export class Tuple{{ narg }}{{ genTupleTypeParamsList(narg) }} implements Tuple
{
    {{- genTupleMembers(narg)}}

    constructor({{genTupleConstructorParams(narg)}}) {
        {{- genTupleCtorSetters(narg)}}
    }

    {{ genToString(narg) }}
}
{%- endfor %}

export class TupleN implements Tuple
{
    $tupleValues: Any[]

    constructor(...p: Any[]) {
        this.$tupleValues = p;
    }
}
